package io;

import java.io.*;
import java.nio.charset.StandardCharsets;
import java.util.Scanner;

/*
完成简易记事本
 */
public class PwDemo2 {
    public static void main(String[] args) throws FileNotFoundException {
        FileOutputStream fos = new FileOutputStream("note.txt");
        OutputStreamWriter osw = new OutputStreamWriter(fos, StandardCharsets.UTF_8);
        BufferedWriter bw = new BufferedWriter(osw);

        PrintWriter pw = new PrintWriter(bw,true);

        Scanner scan = new Scanner(System.in);
        System.out.println("请输入内容,输入exit时退出:");
        while(true){
            String str = scan.nextLine();
            if("exit".equalsIgnoreCase(str)){
                break;
            }
            pw.println(str);//写入字符串
        }
        System.out.println("输入完成,再见!");
        pw.close();
    }
}
